package com.football.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.football.R;
import com.football.model.Channel;

public class ChannelListAdapter extends BaseAdapter {

	private Activity activity;
	private ArrayList<Channel> channelList;
	private static LayoutInflater inflater = null;

	public ChannelListAdapter(Activity act, ArrayList<Channel> list) {
		activity = act;
		channelList = list;
		inflater = (LayoutInflater) activity
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return channelList.size();
	}

	@Override
	public Object getItem(int position) {
		return channelList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	public ArrayList<Channel> getChannelList() {
		return channelList;
	}

	public void setChannelList(ArrayList<Channel> channelList) {
		this.channelList = channelList;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup vg) {
		convertView = inflater.inflate(R.layout.channel, null);
		ImageView channelImg = (ImageView) convertView
				.findViewById(R.id.channelImg);
		TextView url = (TextView) convertView.findViewById(R.id.channelUrl);
		Channel channel = channelList.get(position);
		// channelImg.setImageDrawable(channel.img.getDrawable());
		// channelImg.setImageResource(R.drawable.watch);
		url.setText(channel.name);

		return convertView;
	}

}
